class Solution{
public:
  bool verifyPostorder(vector<int>& postorder){
    return recur(postorder,0,postorder.size()-1);
  }
  bool recur(const vector<int>& postorder, int left, int right){
    if(left >= right) return true;
    int right_left = 0;
    for(int i = left; i < right; ++i){
      if(postorder[i]>postorder[right]){
        right_left = i;
        break;
      } 
    }
    bool left_sub = recur(postorder,left,right_left-1);
    bool right_sub = recur(postorder,right_left,right-1);
    return left_sub && right_sub;
  }
};

//忘记在class的大括号后加；